How to Create a ChildMob?

Started by gustavowizard123 on

Topic category: Help with modding (Java Edition)

Last seen on 19:53, 2. Jun 2021
Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to Create a ChildMob?

hey guys how do i create a child mob with different size? smaller child?

MC 1.15 Mcreator 2020

 

thanks!

Last seen on 19:53, 2. Jun 2021
Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
could i just change…
Mon, 06/15/2020 - 02:08

could i just change something here i do i need a PreRender or something?

 

public void render(MatrixStack ms, IVertexBuilder vb, int i1, int i2, float f1, float f2, float f3, float f4) {

			ms.push();
			ms.scale(0.8f, 0.8f, 0.8f);
			ms.translate(0F, 0.38F, 0F); // translation
			//ms.rotate(Vector3f.YP.rotationDegrees(180.0F)); //rotation
		
			Head.render(ms, vb, i1, i2, f1, f2, f3, f4);
			............
			
			ms.pop();
		}

 

Last seen on 19:53, 2. Jun 2021
Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
'yep' what? i dont get it.
Mon, 06/15/2020 - 02:31

'yep' what? i dont get it.

Last seen on 05:29, 31. Jan 2022
Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
vanilla minecraft does…
Mon, 06/15/2020 - 07:12

vanilla minecraft does something similar except it makes the head a bit bigger than the body to simulate a child.

Last seen on 19:53, 2. Jun 2021
Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
yeah but i could not do it,…
Tue, 06/16/2020 - 02:14

yeah but i could not do it, i look into the codes and i dont see anything i could use my code... you said something about this before, can you light my way ?

 

btw- i will def credit you on my mod when its done, you are one of the few people that are helping me, thank you very much

Last seen on 05:29, 31. Jan 2022
Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
when you say you could not…
Tue, 06/16/2020 - 02:53

when you say you could not do it, do you mean your model doesn't know its a child?

you need to override EntityLivingBase::isChild method. RenderLivingBase will pass that flag onto your model class so your model class can render your entity accordingly. if the above is done, you just do something like 

if (this.isChild) {
    matrixStack.translate(0f, ..., 0f);
    matrixStack.scale(0.25f, 0.25f, 0.25f);
    // render code
    ...
} else {
    matrixStack.translate(0f, ..., 0f);
    matrixStack.scale(0.5f, 0.5f, 0.5f);
    // render code
    ...
}

in your model's render method

Last seen on 19:53, 2. Jun 2021
Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
oooh wait i think i learn…
Tue, 06/16/2020 - 04:37

oooh wait i think i learn something with you just said, yet i cant find the EntityLivingBase::isChild method on the code, the only part with child i see is this

@Override
        public AgeableEntity createChild(AgeableEntity ageable) {
            return (CustomEntity) entity.create(this.world);
        }

 

here is the hole entity

@WizardAnimalsPlusModElements.ModElement.Tag
public class CapuchinBlondEntity extends WizardAnimalsPlusModElements.ModElement {
	public static EntityType entity = null;
	public CapuchinBlondEntity(WizardAnimalsPlusModElements instance) {
		super(instance, 6);
		FMLJavaModLoadingContext.get().getModEventBus().register(this);
	}

	@Override
	public void initElements() {
		entity = (EntityType.Builder.<CustomEntity>create(CustomEntity::new, EntityClassification.CREATURE).setShouldReceiveVelocityUpdates(true)
				.setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(CustomEntity::new).size(0.6f, 1.8f)).build("capuchin_blond")
				.setRegistryName("capuchin_blond");
		elements.entities.add(() -> entity);
		elements.items.add(
			() -> new SpawnEggItem(entity, -5994929, -8425609, new Item.Properties().group(ItemGroup.MISC))
.setRegistryName("capuchin_blond"));
	}

	@Override
	public void init(FMLCommonSetupEvent event) {
		for (Biome biome : ForgeRegistries.BIOMES.getValues()) {
			boolean biomeCriteria = false;
			if (ForgeRegistries.BIOMES.getKey(biome).equals(new ResourceLocation("jungle_hills")))
				biomeCriteria = true;
			if (!biomeCriteria)
				continue;
			biome.getSpawns(EntityClassification.CREATURE).add(new Biome.SpawnListEntry(entity, 4, 1, 4));
		}
		EntitySpawnPlacementRegistry.register(entity, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES,
				AnimalEntity::canAnimalSpawn);
	}

	@SubscribeEvent
	@OnlyIn(Dist.CLIENT)
	public void registerModels(ModelRegistryEvent event) {
		RenderingRegistry.registerEntityRenderingHandler(entity, renderManager -> {
			return new MobRenderer(renderManager, new ModelCapuchin(), 0.5f) {
				@Override
				public ResourceLocation getEntityTexture(Entity entity) {
					return new ResourceLocation("wizard_animals_plus:textures/capuchin_blond.png");
				}
			};
		});
	}
	public static class CustomEntity extends TameableEntity {
		public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
			this(entity, world);
		}

		public CustomEntity(EntityType<CustomEntity> type, World world) {
			super(type, world);
			experienceValue = 2;
			setNoAI(false);
		}

		@Override
		protected void registerGoals() {
			super.registerGoals();
			this.sitGoal = new SitGoal(this);
			this.goalSelector.addGoal(1, new BreedGoal(this, 1.1));
			this.goalSelector.addGoal(2, new RandomWalkingGoal(this, 1));
			this.goalSelector.addGoal(3, new LookAtGoal(this, PlayerEntity.class, (float) 6));
			this.goalSelector.addGoal(4, new LookRandomlyGoal(this));
			this.goalSelector.addGoal(5, new SwimGoal(this));
			this.goalSelector.addGoal(6, new TemptGoal(this, 1.1, Ingredient.fromItems(new ItemStack(Items.SUGAR_CANE, (int) (1)).getItem()), false));
			this.goalSelector.addGoal(7, new PanicGoal(this, 1.2));
			this.goalSelector.addGoal(8, new FollowParentGoal(this, 0.8));
			
			this.goalSelector.addGoal(9, this.sitGoal);
			this.goalSelector.addGoal(10, new FollowOwnerGoal(this, 1.0D, 10.0F, 2.0F, false));
		}

		//TAME CODE
    public void setTamed(boolean tamed)
    {
    	super.setTamed(tamed);
       //whatever you want your mob to do when it's tamed e.g. the wolf's class uses this to increase the mob's max health to 20 if it's tamed

    }

	public boolean processInteract(PlayerEntity player, Hand handIn)
	{
	  ItemStack itemstack = player.getHeldItem(handIn);
	  if (!this.isTamed() && itemstack.getItem() == Items.APPLE && !this.isBreedingItem(itemstack))
	    {
	      if (!player.abilities.isCreativeMode)
	        {
	            itemstack.shrink(1);
	        }
	     if (!this.world.isRemote)
	        {
	            if (this.rand.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, player))
	            {
	                this.setTamedBy(player);
	                this.navigator.clearPath();
	                this.setAttackTarget((LivingEntity)null);
	                this.sitGoal.setSitting(true);
	                this.setHealth(8.0F);
	                this.playTameEffect(true);
	                this.world.setEntityState(this, (byte)7);
	            }
	            else
	            {
	                this.playTameEffect(false);
	                this.world.setEntityState(this, (byte)6);
	            }
	        }
	        return true;
	    }
	
	    else if (this.isOwner(player) && !this.world.isRemote && !this.isBreedingItem(itemstack))
	    {
	         this.sitGoal.setSitting(!this.isSitting()); 
	         this.isJumping = false;
	         this.navigator.clearPath();
	         this.setAttackTarget((LivingEntity)null); 
	         return true;
	    }
	
	    return super.processInteract(player, handIn);
	}
		//TAME CODE END

		@Override
		public CreatureAttribute getCreatureAttribute() {
			return CreatureAttribute.UNDEFINED;
		}

		protected void dropSpecialItems(DamageSource source, int looting, boolean recentlyHitIn) {
			super.dropSpecialItems(source, looting, recentlyHitIn);
		}

		@Override
		public net.minecraft.util.SoundEvent getAmbientSound() {
			return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS
					.getValue(new ResourceLocation("wizard_animals_plus:capuchin_ambient"));
		}

		@Override
		public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
			return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("wizard_animals_plus:capuchin_hurt"));
		}

		@Override
		public net.minecraft.util.SoundEvent getDeathSound() {
			return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("wizard_animals_plus:capuchin_death"));
		}

		@Override
		protected float getSoundVolume() {
			return 1.0F;
		}

		@Override
		protected void registerAttributes() {
			super.registerAttributes();
			if (this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED) != null)
				this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.35);
			if (this.getAttribute(SharedMonsterAttributes.MAX_HEALTH) != null)
				this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(8);
			if (this.getAttribute(SharedMonsterAttributes.ARMOR) != null)
				this.getAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(0);
			if (this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) == null)
				this.getAttributes().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE);
			this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(0);
		}

		@Override
		public AgeableEntity createChild(AgeableEntity ageable) {
			return (CustomEntity) entity.create(this.world);
		}

		@Override
		public boolean isBreedingItem(ItemStack stack) {
			if (stack == null)
				return false;
			if (new ItemStack(Items.SUGAR_CANE, (int) (1)).getItem() == stack.getItem())
				return true;
			return false;
		}
	}

	// Date: 08/12/2017 01:22:10
	// Template version 1.1
	// Java generated by Techne
	// Keep in mind that you still need to fill in some blanks
	// - ZeuX
	public static class ModelCapuchin extends EntityModel<Entity> {
		// fields
		ModelRenderer Head;
		ModelRenderer Body;
		ModelRenderer ArmL;
		ModelRenderer ArmR;
		ModelRenderer TailBase;
		ModelRenderer TailTip;
		ModelRenderer UpLeg2;
		ModelRenderer DownLeg2;
		ModelRenderer Foot2;
		ModelRenderer UpLeg1;
		ModelRenderer DownLeg1;
		ModelRenderer Foot1;
		ModelRenderer Face;
		ModelRenderer EarL;
		ModelRenderer EarR;
		ModelRenderer Nose;
		public ModelCapuchin() {
			textureWidth = 64;
			textureHeight = 64;
			Head = new ModelRenderer(this, 42, 2);
			Head.addBox(-2.5F, -5F, -3.5F, 5, 5, 5);
			Head.setRotationPoint(0.5F, 15F, -1F);
			Head.setTextureSize(64, 64);
			Head.mirror = true;
			setRotation(Head, 0F, 0F, 0F);
			Body = new ModelRenderer(this, 23, 2);
			Body.addBox(-1.5F, -2F, -1F, 4, 8, 4);
			Body.setRotationPoint(0F, 16.5F, -0.5F);
			Body.setTextureSize(64, 64);
			Body.mirror = true;
			setRotation(Body, 1.047198F, 0F, 0F);
			ArmL = new ModelRenderer(this, 34, 16);
			ArmL.addBox(0F, 0F, -0.5F, 1, 9, 1);
			ArmL.setRotationPoint(2F, 15.5F, -1F);
			ArmL.setTextureSize(64, 64);
			ArmL.mirror = true;
			setRotation(ArmL, -0.3490659F, 0F, 0F);
			ArmR = new ModelRenderer(this, 40, 16);
			ArmR.addBox(-1F, 0F, -0.5F, 1, 9, 1);
			ArmR.setRotationPoint(-1F, 15.5F, -1F);
			ArmR.setTextureSize(64, 64);
			ArmR.mirror = true;
			setRotation(ArmR, -0.3490659F, 0F, 0F);
			TailBase = new ModelRenderer(this, 16, 4);
			TailBase.addBox(-0.5F, -5F, -0.5F, 1, 5, 1);
			TailBase.setRotationPoint(0.5F, 17F, 5F);
			TailBase.setTextureSize(64, 64);
			TailBase.mirror = true;
			setRotation(TailBase, -0.7853982F, 0F, 0F);
			TailTip = new ModelRenderer(this, 11, 4);
			TailTip.addBox(-0.5F, -7.5F, 3.5F, 1, 5, 1);
			TailTip.setRotationPoint(0.5F, 17F, 5F);
			TailTip.setTextureSize(64, 64);
			TailTip.mirror = true;
			setRotation(TailTip, 0.1745329F, 0F, 0F);
			UpLeg2 = new ModelRenderer(this, 14, 23);
			UpLeg2.addBox(-1F, -1F, -1F, 2, 5, 2);
			UpLeg2.setRotationPoint(2F, 19F, 4.5F);
			UpLeg2.setTextureSize(64, 64);
			UpLeg2.mirror = true;
			setRotation(UpLeg2, -0.7853982F, 0F, 0F);
			DownLeg2 = new ModelRenderer(this, 14, 31);
			DownLeg2.addBox(-1F, -1F, -4F, 2, 4, 1);
			DownLeg2.setRotationPoint(2F, 19F, 4.5F);
			DownLeg2.setTextureSize(64, 64);
			DownLeg2.mirror = true;
			setRotation(DownLeg2, 0.7853982F, 0F, 0F);
			Foot2 = new ModelRenderer(this, 15, 37);
			Foot2.addBox(-1F, 4F, -3F, 2, 1, 3);
			Foot2.setRotationPoint(2F, 19F, 4.5F);
			Foot2.setTextureSize(64, 64);
			Foot2.mirror = true;
			setRotation(Foot2, 0F, 0F, 0F);
			UpLeg1 = new ModelRenderer(this, 2, 23);
			UpLeg1.addBox(-1F, -1F, -1F, 2, 5, 2);
			UpLeg1.setRotationPoint(-1F, 19F, 4.5F);
			UpLeg1.setTextureSize(64, 64);
			UpLeg1.mirror = true;
			setRotation(UpLeg1, -0.7853982F, 0F, 0F);
			DownLeg1 = new ModelRenderer(this, 4, 31);
			DownLeg1.addBox(-1F, -1F, -4F, 2, 4, 1);
			DownLeg1.setRotationPoint(-1F, 19F, 4.5F);
			DownLeg1.setTextureSize(64, 64);
			DownLeg1.mirror = true;
			setRotation(DownLeg1, 0.7853982F, 0F, 0F);
			Foot1 = new ModelRenderer(this, 3, 37);
			Foot1.addBox(-1F, 4F, -3F, 2, 1, 3);
			Foot1.setRotationPoint(-1F, 19F, 4.5F);
			Foot1.setTextureSize(64, 64);
			Foot1.mirror = true;
			setRotation(Foot1, 0F, 0F, 0F);
			Face = new ModelRenderer(this, 50, 17);
			Face.addBox(-2F, -4.5F, -3.8F, 4, 4, 1);
			Face.setRotationPoint(0.5F, 15F, -1F);
			Face.setTextureSize(64, 64);
			Face.mirror = true;
			setRotation(Face, 0F, 0F, 0F);
			EarL = new ModelRenderer(this, 2, 8);
			EarL.addBox(0F, -4F, -3F, 2, 2, 2);
			EarL.setRotationPoint(0.5F, 15F, -1F);
			EarL.setTextureSize(64, 64);
			EarL.mirror = true;
			setRotation(EarL, 0F, -0.7853982F, 0F);
			EarR = new ModelRenderer(this, 2, 2);
			EarR.addBox(-2F, -4F, -3F, 2, 2, 2);
			EarR.setRotationPoint(0.5F, 15F, -1F);
			EarR.setTextureSize(64, 64);
			EarR.mirror = true;
			setRotation(EarR, 0F, 0.7853982F, 0F);
			Nose = new ModelRenderer(this, 50, 24);
			Nose.addBox(-1F, -2.8F, -4.5F, 2, 2, 2);
			Nose.setRotationPoint(0.5F, 15F, -1F);
			Nose.setTextureSize(64, 64);
			Nose.mirror = true;
			setRotation(Nose, 0.0872665F, 0F, 0F);
		}

		public void render(MatrixStack ms, IVertexBuilder vb, int i1, int i2, float f1, float f2, float f3, float f4) {

			ms.push();
			ms.scale(0.8f, 0.8f, 0.8f);
			ms.translate(0F, 0.38F, 0F); // translation
			//ms.rotate(Vector3f.YP.rotationDegrees(180.0F)); //rotation
		
			Head.render(ms, vb, i1, i2, f1, f2, f3, f4);
			Body.render(ms, vb, i1, i2, f1, f2, f3, f4);
			ArmL.render(ms, vb, i1, i2, f1, f2, f3, f4);
			ArmR.render(ms, vb, i1, i2, f1, f2, f3, f4);
			TailBase.render(ms, vb, i1, i2, f1, f2, f3, f4);
			TailTip.render(ms, vb, i1, i2, f1, f2, f3, f4);
			UpLeg2.render(ms, vb, i1, i2, f1, f2, f3, f4);
			DownLeg2.render(ms, vb, i1, i2, f1, f2, f3, f4);
			Foot2.render(ms, vb, i1, i2, f1, f2, f3, f4);
			UpLeg1.render(ms, vb, i1, i2, f1, f2, f3, f4);
			DownLeg1.render(ms, vb, i1, i2, f1, f2, f3, f4);
			Foot1.render(ms, vb, i1, i2, f1, f2, f3, f4);
			Face.render(ms, vb, i1, i2, f1, f2, f3, f4);
			EarL.render(ms, vb, i1, i2, f1, f2, f3, f4);
			EarR.render(ms, vb, i1, i2, f1, f2, f3, f4);
			Nose.render(ms, vb, i1, i2, f1, f2, f3, f4);
			
			ms.pop();
		}


		private void setRotation(ModelRenderer model, float x, float y, float z) {
			model.rotateAngleX = x;
			model.rotateAngleY = y;
			model.rotateAngleZ = z;
		}

		public void setRotationAngles(Entity entity, float f, float f1, float f2, float f3, float f4) {
		this.Head.rotateAngleY = f3 / (180F / (float) Math.PI);
               this.Head.rotateAngleX = f4 / (180F / (float) Math.PI);

               this.Face.rotateAngleY = f3 / (180F / (float) Math.PI);
               this.Face.rotateAngleX = f4 / (180F / (float) Math.PI);

               this.Nose.rotateAngleY = f3 / (180F / (float) Math.PI);
               this.Nose.rotateAngleX = f4 / (180F / (float) Math.PI) + 0.0872665F;

               this.EarL.rotateAngleY = f3 / (180F / (float) Math.PI) - 0.7853982F;
               this.EarL.rotateAngleX = f4 / (180F / (float) Math.PI);

               this.EarR.rotateAngleY = f3 / (180F / (float) Math.PI) + 0.7853982F;
               this.EarR.rotateAngleX = f4 / (180F / (float) Math.PI);

               this.TailBase.rotateAngleY = f3 / (180F / (float) Math.PI);
               this.TailTip.rotateAngleY = f3 / (180F / (float) Math.PI);

               this.ArmL.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1  -0.3490659F;
			   this.ArmR.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * 1.4F * f1  -0.3490659F;
			   this.UpLeg1.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1 - 0.7853982F;
               this.DownLeg1.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1 + 0.7853982F;
               this.Foot1.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1;
               this.UpLeg2.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * 1.4F * f1 - 0.7853982F;
               this.DownLeg2.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * 1.4F * f1 + 0.7853982F;
               this.Foot2.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * 1.4F * f1;
		}

 

Last seen on 19:53, 2. Jun 2021
Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
lol it actually worked with…
Tue, 06/16/2020 - 04:45

lol it actually worked with just that simple code on the reder.. the child is scaled now, but i notice it wont grow lol.. i supose i need something else to make it grow too?

 

thanks again btw!

Last seen on 19:53, 2. Jun 2021
Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
lol i think it actually…
Tue, 06/16/2020 - 04:59

lol i think it actually grows it just took like 10min wow cool! thanks a lot friend!

Last seen on 05:29, 31. Jan 2022
Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
you have to implement your…
Tue, 06/16/2020 - 05:58

you have to implement your own isChild method. add something like this in your entity class:

@Override
public boolean isChild() {
    if (/*code to determine if child*/) {
        return true;
    }
    return false;
}

 

Last seen on 19:53, 2. Jun 2021
Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
oh? but its already growing…
Tue, 06/16/2020 - 06:02

oh? but its already growing i need that for what again?

thanks

Last seen on 14:43, 2. Aug 2022
Joined Nov 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
To determine when it will be…
Tue, 06/16/2020 - 09:15

To determine when it will be an adult.

Last seen on 19:39, 19. Nov 2022
Joined Mar 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
hello is not programmed how…
Tue, 06/16/2020 - 14:35

hello is not programmed how I use this