Jump to content

SilasOtoko

Members
  • Posts

    92
  • Joined

  • Last visited

Everything posted by SilasOtoko

  1. Ooops, sorry. Here is the code: The Tasks this.targetTasks.addTask(2, new EntityAIHurtByTarget(this, false)); this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityLiving.class, 16.0F, 0, false, true, IMob.mobSelector)); The Constructors protected void collideWithEntity(Entity par1Entity) { if (par1Entity instanceof IMob && !(par1Entity instanceof EntityEnt) && this.getRNG().nextInt(20) == 0) { this.setAttackTarget((EntityLiving)par1Entity); } super.collideWithEntity(par1Entity); } public boolean canAttackClass(Class par1Class) { return this.isPlayerCreated() && EntityPlayer.class.isAssignableFrom(par1Class) ? false : super.canAttackClass(par1Class); } public boolean attackEntityAsMob(Entity par1Entity) { this.attackTimer = 10; this.worldObj.setEntityState(this, (byte)4); boolean flag = par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), 7 + this.rand.nextInt(15)); if (flag) { par1Entity.motionY += 0.4000000059604645D; } this.playSound("mob.irongolem.throw", 1.0F, 1.0F); return flag; }
  2. Yes, I understand coding is important when making a mod... I know that it has to do with the Imob Selector, but I can't seem to find the base code where it decides what a golem attacks and what it doesn't.
  3. I made a custom mob that I want to make attack hostile mobs just like an IronGolem. I've been able to make this work, problem is that it also targets any other Custom Mob of the same type in the area. How can I make it see fellow Custom Mobs not as enemies?
  4. I'm working on a custom mob that spawns in the Forest, which I already have working, but on top of that I want that mob to stay in the forest all the time and not wander into other Biomes. I could use something as simple as limiting the mob to wandering 30-50 blocks from its spawn point for example. Anyone know how to do this? It's based off the same idea that keeps an Iron Golem inside of a village. Thanks!
  5. Try to take it a little easy on me. This is my first minecraft mod and I am just trying out everything to do a trial and error method of figuring out what works. I am a kinesthetic learner so I learn best by doing. I fixed the first problem with the constructor, something which I copied from a tutorial example online, and since my mod is a biped I removed the Quadrupled bit. The last problem with the Entity ID is fixed but I'm not sure what I need to change to render it only on client side? By the way the rendering of the items on top of my model works if anyone was wondering. It's the same way that Mushrooms are on the back of the mooshroom. Only thing is that the details of the placement need to be changed to suit your specific model. I didn't change it on mine because that's a little beyond what I know how to do and the way it turned out on my model suits me just fine.
  6. Well I found where the code is. Now I am only having issues with my custom mob rendering. It spawns in the world, but it is invisible, and somehow it is overlapping with my custom throwable item, because it shows the image of the item in place of the mob texture. Render @SideOnly(Side.CLIENT) public class RenderEnt extends RenderLiving { /** Iron Golem's Model. */ protected ModelEnt ModelEnt; public RenderEnt(ModelEnt model, float f) { super(new ModelEnt(), 0.5F); model = (ModelEnt)mainModel; } public void renderLivingEnt(EntityEnt par1EntityEnt, double par2, double par4, double par6, float par8, float par9) { super.doRenderLiving(par1EntityEnt, par2, par4, par6, par8, par9); } protected void renderEntEquippedItems(EntityEnt par1EntityEnt, float par2) { super.renderEquippedItems(par1EntityEnt, par2); if (!par1EntityEnt.isChild()) { this.loadTexture("/terrain.png"); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glPushMatrix(); GL11.glScalef(1.0F, -1.0F, 1.0F); GL11.glTranslatef(0.2F, 0.4F, 0.5F); GL11.glRotatef(42.0F, 0.0F, 1.0F, 0.0F); this.renderBlocks.renderBlockAsItem(Block.sapling, 0, 1.0F); GL11.glTranslatef(0.1F, 0.0F, -0.6F); GL11.glRotatef(42.0F, 0.0F, 1.0F, 0.0F); this.renderBlocks.renderBlockAsItem(Block.sapling, 0, 1.0F); GL11.glPopMatrix(); GL11.glPushMatrix(); ((ModelQuadruped)this.mainModel).head.postRender(0.0625F); GL11.glScalef(1.0F, -1.0F, 1.0F); GL11.glTranslatef(0.0F, 0.75F, -0.2F); GL11.glRotatef(12.0F, 0.0F, 1.0F, 0.0F); this.renderBlocks.renderBlockAsItem(Block.sapling, 0, 1.0F); GL11.glPopMatrix(); GL11.glDisable(GL11.GL_CULL_FACE); } } protected void renderEquippedItems(EntityLiving par1EntityLiving, float par2) { this.renderEntEquippedItems((EntityEnt)par1EntityLiving, par2); } public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) { this.renderLivingEnt((EntityEnt)par1EntityLiving, par2, par4, par6, par8, par9); } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1, * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. */ public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { this.renderLivingEnt((EntityEnt)par1Entity, par2, par4, par6, par8, par9); } } Entity public class EntityEnt extends EntityMob { public EntityEnt(World par1World){ super(par1World); this.texture = "/mob/villager_golem.png"; this.setSize(1.4F, 2.9F); this.getNavigator().setAvoidsWater(true); this.tasks.addTask(1, new EntityAIAttackOnCollide(this, 0.25F, true)); this.tasks.addTask(2, new EntityAIMoveTowardsTarget(this, 0.22F, 32.0F)); this.tasks.addTask(4, new EntityAIMoveTwardsRestriction(this, 0.16F)); this.tasks.addTask(5, new EntityAIWander(this, 0.16F)); this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); this.tasks.addTask(7, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); } public String getTexture() { return "/mob/villager_golem.png"; } @Override public int getMaxHealth() { return 100; } /** * Returns true if the newer Entity AI code should be run */ public boolean isAIEnabled() { return true; } /** * Decrements the entity's air supply when underwater */ protected int decreaseAirSupply(int par1) { return par1; } /** * Returns the sound this mob makes while it's alive. */ protected String getLivingSound() { return "none"; } /** * Returns the sound this mob makes when it is hurt. */ protected String getHurtSound() { return "mob.irongolem.hit"; } /** * Returns the sound this mob makes on death. */ protected String getDeathSound() { return "mob.irongolem.death"; } /** * Plays step sound at given x, y, z for the entity */ protected void playStepSound(int par1, int par2, int par3, int par4) { this.playSound("mob.irongolem.walk", 1.0F, 1.0F); } /** * Drop 0-2 items of this living's type. @param par1 - Whether this entity has recently been hit by a player. @param * par2 - Level of Looting used to kill this mob. */ protected void dropFewItems(boolean par1, int par2) { int j = this.rand.nextInt(3); int k; for (k = 0; k < j; ++k) { this.dropItem(TutorialMod.EarthRune.itemID, 1); } k = 3 + this.rand.nextInt(3); for (int l = 0; l < k; ++l) { this.dropItem(TutorialMod.SilverNugget.itemID, 4); } } } Main Class Custom Registers GameRegistry.registerWorldGenerator(new WorldGeneratorJosiah()); EntityRegistry.registerModEntity(EntityCreeperHeart.class, "CreeperHeart", 1, this, 80, 3, true); LanguageRegistry.instance().addStringLocalization("entity.CreeperHeart.name", "CreeperHeart"); RenderingRegistry.registerEntityRenderingHandler(EntityCreeperHeart.class, new RenderCreeperHeart(TutorialMod.CreeperHeart)); EntityRegistry.registerModEntity(EntityEnt.class, "Ent", 1, this, 40, 1, true); EntityRegistry.addSpawn(EntityEnt.class, 10, 1, 7, EnumCreatureType.monster, BiomeGenBase.beach, BiomeGenBase.extremeHills, BiomeGenBase.extremeHillsEdge, BiomeGenBase.forest, BiomeGenBase.forestHills, BiomeGenBase.jungle, BiomeGenBase.jungleHills, BiomeGenBase.mushroomIsland, BiomeGenBase.mushroomIslandShore, BiomeGenBase.ocean, BiomeGenBase.plains, BiomeGenBase.river, BiomeGenBase.swampland); LanguageRegistry.instance().addStringLocalization("entity.Josiah.FirstMod_TutorialMod.Tutorial.name", "Ent"); RenderingRegistry.registerEntityRenderingHandler(EntityEnt.class, new RenderEnt(new ModelEnt(), 0.5F));
  7. Anyone know what part of the code deals with the mooshrooms having mushrooms on their backs? I'm looking to make a custom mob with saplings growing on the mob, and I can't figure it out from looking at the mooshroom code.
  8. Can you give me a good example of what you mean with the null pointer? I work best with visual examples. Are you talking about this? rand = Math.random();
  9. That is really useful. I'll probably try to use that at some point. Thank you!
  10. I've just recently figured out how to make this work, after many hours of searching the internet and help forums. So if any of you have had the same problem and faced the same frustration as I have, let me help you out by giving you an example of working code. The number in (rand < 0.1D) is how often you want the item to drop. 1D = 100% so .5D is 50% and so on. The number after your item is how many of that Item you want the mob to drop. You have to make a new class to put this in and then register this event in your main class like this: You have to put this in your "public void load" constructor. Hope this helps someone!
  11. I finally figured this out for myself! If anyone is still interested in how this works, here is an example of the code: The part where you put in your custom item needs to be in the format of YourMod.YourItem.itemID. This is for 1.5.2 by the way.
  12. Yay! I got it to work! Thanks GoToLink for the help! The tip on extending BlockSapling helped tremendously! I was able to figure it out after that by commenting out all the different parts until I better understood what each part did. I will post the code now for anyone who is curious about making their own.
  13. Alright, I extended the BlockSapling class, but now my saplings appear as regular oak saplings that grow into my custom tree. So I need to make the class choose my custom texture. Also, if anyone has any input on how I can clean up this code to get rid of the parts I don't need I would appreciate it.
  14. I'm currently trying to make my custom sapling grow into my custom tree. I copied over the files from the vanilla sapling class, but I'm not sure how to get around the biome specific tree growth. When I use bone meal on my sapling, it changes into a regular oak tree. Any help would be appreciated! Custom Sapling Here is the new code that actually works:
  15. I'm having the exact opposite problem as you. I've made a working custom bonemeal but I don't know how to make my custom sapling grow into my custom tree. If you are still looking for an answer here is all I needed to make my custom bonemeal. If you ever read this could you post about how you made your custom sapling work? Thanks!
  16. I would also like to see a tutorial on this! Whatever works! I have been trying to have a custom flower spawn in the world but with no luck. I can't seem to find a proper tutorial for generating custom flowers for Minecraft 1.5.
  17. I think somehow I just overlapped the item ID for black dye. I did copy and paste the code into my own file, but I assumed that I had changed what was needed and removed anything tying it back into the item ID's for the dyes.
×
×
  • Create New...

Important Information

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