Topic category: Help with Minecraft modding (Java Edition)
hello gustavowizard123 and ahznb I see that you two know how to make a baby mob in 1.15 you could edit my code to generate a baby mob
package net.mcreator.varius.entity;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.fml.network.FMLPlayMessages;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraft.world.gen.Heightmap;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.World;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.DamageSource;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.SpawnEggItem;
import net.minecraft.item.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.Item;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.ai.goal.TemptGoal;
import net.minecraft.entity.ai.goal.SwimGoal;
import net.minecraft.entity.ai.goal.RandomWalkingGoal;
import net.minecraft.entity.ai.goal.MeleeAttackGoal;
import net.minecraft.entity.ai.goal.LookRandomlyGoal;
import net.minecraft.entity.ai.goal.HurtByTargetGoal;
import net.minecraft.entity.ai.goal.FollowParentGoal;
import net.minecraft.entity.ai.goal.FollowMobGoal;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.EntitySpawnPlacementRegistry;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.Entity;
import net.minecraft.entity.CreatureAttribute;
import net.minecraft.entity.AgeableEntity;
import net.minecraft.client.renderer.model.ModelRenderer;
import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.mcreator.varius.VariusModElements;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.mojang.blaze3d.matrix.MatrixStack;
@VariusModElements.ModElement.Tag
public class GallinadeguinaEntity extends VariusModElements.ModElement {
public static EntityType entity = null;
public GallinadeguinaEntity(VariusModElements instance) {
super(instance, 24);
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("gallinadeguina")
.setRegistryName("gallinadeguina");
elements.entities.add(() -> entity);
elements.items.add(() -> new SpawnEggItem(entity, -1, -1, new Item.Properties().group(ItemGroup.MISC)).setRegistryName("gallinadeguina"));
}
@Override
public void init(FMLCommonSetupEvent event) {
for (Biome biome : ForgeRegistries.BIOMES.getValues()) {
biome.getSpawns(EntityClassification.CREATURE).add(new Biome.SpawnListEntry(entity, 20, 4, 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 Modelchicken(), 0.5f) {
@Override
public ResourceLocation getEntityTexture(Entity entity) {
return new ResourceLocation("varius:textures/chicken.png");
}
};
});
}
public static class CustomEntity extends AnimalEntity {
public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
this(entity, world);
}
public CustomEntity(EntityType<CustomEntity> type, World world) {
super(type, world);
experienceValue = 0;
setNoAI(false);
}
@Override
protected void registerGoals() {
super.registerGoals();
this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.2, false));
this.goalSelector.addGoal(2, new RandomWalkingGoal(this, 1));
this.targetSelector.addGoal(3, new HurtByTargetGoal(this));
this.goalSelector.addGoal(4, new LookRandomlyGoal(this));
this.goalSelector.addGoal(5, new SwimGoal(this));
this.goalSelector.addGoal(6, new TemptGoal(this, 1, Ingredient.fromItems(new ItemStack(Items.WHEAT_SEEDS, (int) (1)).getItem()), false));
this.goalSelector.addGoal(7, new FollowParentGoal(this, 0.8));
this.goalSelector.addGoal(8, new FollowMobGoal(this, (float) 1, 10, 5));
}
@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(""));
}
@Override
public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.generic.hurt"));
}
@Override
public net.minecraft.util.SoundEvent getDeathSound() {
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.generic.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.3);
if (this.getAttribute(SharedMonsterAttributes.MAX_HEALTH) != null)
this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(10);
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(3);
}
@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.WHEAT_SEEDS, (int) (1)).getItem() == stack.getItem())
return true;
return false;
}
}
// Made with Blockbench 3.5.4
// Exported for Minecraft version 1.15
// Paste this class into your mod and generate all required imports
public static class Modelchicken extends EntityModel<Entity> {
private final ModelRenderer body;
private final ModelRenderer head;
private final ModelRenderer leg0;
private final ModelRenderer leg1;
private final ModelRenderer wing0;
private final ModelRenderer wing1;
public Modelchicken() {
textureWidth = 64;
textureHeight = 32;
body = new ModelRenderer(this);
body.setRotationPoint(0.0F, 16.0F, 0.0F);
body.setTextureOffset(0, 9).addBox(-4.0F, -4.0F, -3.0F, 6.0F, 8.0F, 10.0F, 0.0F, true);
body.setTextureOffset(17, 0).addBox(-1.0F, -3.0F, 7.0F, 1.0F, 5.0F, 4.0F, 0.0F, false);
head = new ModelRenderer(this);
head.setRotationPoint(0.0F, -1.0F, -4.0F);
body.addChild(head);
head.setTextureOffset(33, 26).addBox(-3.0F, -9.0F, -1.0F, 4.0F, 3.0F, 3.0F, 0.0F, true);
head.setTextureOffset(48, 20).addBox(-2.0F, -6.0F, -1.0F, 2.0F, 6.0F, 3.0F, 0.0F, false);
head.setTextureOffset(0, 0).addBox(-1.0F, -12.0F, 0.0F, 0.0F, 3.0F, 4.0F, 0.0F, false);
head.setTextureOffset(56, 28).addBox(-2.0F, -8.0F, -3.0F, 2.0F, 2.0F, 2.0F, 0.0F, true);
head.setTextureOffset(0, 0).addBox(-2.0F, -6.0F, -2.0F, 2.0F, 1.0F, 1.0F, 0.0F, false);
leg0 = new ModelRenderer(this);
leg0.setRotationPoint(2.0F, 19.0F, 1.0F);
leg0.setTextureOffset(26, 0).addBox(-3.0F, 0.0F, 0.0F, 3.0F, 5.0F, 3.0F, 0.0F, true);
leg1 = new ModelRenderer(this);
leg1.setRotationPoint(-1.0F, 19.0F, 1.0F);
leg1.setTextureOffset(26, 0).addBox(-4.0F, 0.0F, 0.0F, 3.0F, 5.0F, 3.0F, 0.0F, true);
wing0 = new ModelRenderer(this);
wing0.setRotationPoint(3.0F, 13.0F, 0.0F);
wing0.setTextureOffset(50, 0).addBox(-1.0F, 1.0F, -2.0F, 1.0F, 4.0F, 6.0F, 0.0F, true);
wing1 = new ModelRenderer(this);
wing1.setRotationPoint(-4.5F, 16.0F, 1.0F);
setRotationAngle(wing1, 0.0F, 0.0F, -3.1416F);
wing1.setTextureOffset(50, 0).addBox(-0.5F, -2.0F, -3.0F, 1.0F, 4.0F, 6.0F, 0.0F, true);
}
@Override
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
float alpha) {
body.render(matrixStack, buffer, packedLight, packedOverlay);
leg0.render(matrixStack, buffer, packedLight, packedOverlay);
leg1.render(matrixStack, buffer, packedLight, packedOverlay);
wing0.render(matrixStack, buffer, packedLight, packedOverlay);
wing1.render(matrixStack, buffer, packedLight, packedOverlay);
}
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
modelRenderer.rotateAngleX = x;
modelRenderer.rotateAngleY = y;
modelRenderer.rotateAngleZ = z;
}
public void setRotationAngles(Entity e, 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.leg0.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1;
this.leg1.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1;
}
}
}
in case i can use a custom baby model attached my baby model
// Made with Blockbench 3.5.4
// Exported for Minecraft version 1.15
// Paste this class into your mod and generate all required imports
public class geometry.chicken extends EntityModel<Entity> {
private final ModelRenderer body;
private final ModelRenderer head;
private final ModelRenderer leg0;
private final ModelRenderer leg1;
private final ModelRenderer wing0;
private final ModelRenderer wing1;
public geometry.chicken() {
textureWidth = 64;
textureHeight = 32;
body = new ModelRenderer(this);
body.setRotationPoint(0.0F, 16.0F, 0.0F);
body.setTextureOffset(0, 0).addBox(-2.8F, 2.0F, -3.0F, 4.0F, 4.0F, 6.0F, 0.0F, false);
body.setTextureOffset(2, 22).addBox(-0.8F, 2.5F, 3.0F, 0.0F, 3.0F, 4.0F, 0.0F, false);
head = new ModelRenderer(this);
head.setRotationPoint(0.0F, -1.0F, -4.0F);
body.addChild(head);
head.setTextureOffset(32, 18).addBox(-2.6F, -3.0F, -1.0F, 4.0F, 4.0F, 4.0F, 0.0F, false);
head.setTextureOffset(56, 28).addBox(-1.6F, -2.0F, -3.0F, 2.0F, 2.0F, 2.0F, 0.0F, false);
head.setTextureOffset(48, 20).addBox(-1.7F, 1.0F, 0.0F, 2.0F, 3.0F, 2.0F, 0.0F, false);
leg0 = new ModelRenderer(this);
leg0.setRotationPoint(2.0F, 3.0F, 1.0F);
body.addChild(leg0);
leg0.setTextureOffset(26, 0).addBox(-3.0F, 3.0F, -3.0F, 3.0F, 2.0F, 3.0F, 0.0F, true);
leg1 = new ModelRenderer(this);
leg1.setRotationPoint(-1.0F, 3.0F, 1.0F);
body.addChild(leg1);
leg1.setTextureOffset(32, 11).addBox(-2.5F, 3.0F, -3.0F, 3.0F, 2.0F, 3.0F, 0.0F, true);
wing0 = new ModelRenderer(this);
wing0.setRotationPoint(3.0F, -3.0F, 0.0F);
body.addChild(wing0);
wing0.setTextureOffset(48, 0).addBox(-1.8F, 5.5F, -2.0F, 1.0F, 3.0F, 4.0F, 0.0F, false);
wing1 = new ModelRenderer(this);
wing1.setRotationPoint(-4.5F, 0.0F, 1.0F);
body.addChild(wing1);
wing1.setTextureOffset(48, 8).addBox(0.7F, 2.5F, -3.0F, 1.0F, 3.0F, 4.0F, 0.0F, false);
}
@Override
public void setRotationAngles(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch){
//previously the render function, render code was moved to a method below
}
@Override
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){
body.render(matrixStack, buffer, packedLight, packedOverlay);
}
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
modelRenderer.rotateAngleX = x;
modelRenderer.rotateAngleY = y;
modelRenderer.rotateAngleZ = z;
}
}
and the texture
Do not ping users in titles. Please check https://mcreator.net/wiki/general-publishing-guidelines
sorry
lol why i would i need your texture man??
my post was about it, all you need to know is there... but you need to change that one before last part there to:
@Override
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){
ms.push();
ms.scale (Xf, Xf, Xf); /// <--- X is your scale here
ms.translate (0F, YF, 0F); // <------ Y is your scale height fix, you can use the formula that ahznb gave or figger it out by yourself
body.render(matrixStack, buffer, packedLight, packedOverlay);
ms.pop();
}
i made this aproximate table for the Y value there
SCALE Y
0.07 19.8
0.1 13.5
0.15 8.5
0.2 5.8
0.3
0.4 2.2
0.5
0.6 1.0
0.7
0.8 0.38
0.9
1.0 0.0
1.1
1.2 -0.25
1.3 -0.34
1.4 -0.42
hope it helps! GL
thank you very much for everything if it works
hey could you tell me if this is a bug
nothing happens when you start the breeding process