Started by
gustavowizard123
on
Topic category: Help with Minecraft modding (Java Edition)
Hey guys! nice software btw;
how do i change the code of a Mob to scale its model down/up? i use to do it easy on MCreator 1.8 for MC 1.12, but i cant do bananas with new Mcreator 2020 for MC 1.15... can someone please light my way here?
thanks!
put this line "ms.translate(0f, 1.5f - scale * 1.5f, 0f);" before the scaling code, where scale is 0.25
I made my model in BlockBench, I cant find where you told me to put. This is my example model, is there any differences?
public class DireWolves extends EntityModel<Entity> {
private final ModelRenderer WolfHead;
private final ModelRenderer Ear1;
private final ModelRenderer Ear2;
private final ModelRenderer Nose;
private final ModelRenderer Body;
private final ModelRenderer Mane;
private final ModelRenderer Leg1;
private final ModelRenderer Leg2;
private final ModelRenderer Leg3;
private final ModelRenderer Leg4;
private final ModelRenderer Tail;
public DireWolves() {
textureWidth = 128;
textureHeight = 64;
WolfHead = new ModelRenderer(this);
WolfHead.setRotationPoint(-1.0F, 13.5F, -7.0F);
WolfHead.setTextureOffset(2, 0).addBox(-4.0F, -5.5F, -8.0F, 8.0F, 8.0F, 6.0F, 0.0F, true);
Ear1 = new ModelRenderer(this);
Ear1.setRotationPoint(0.0F, 0.0F, 0.0F);
WolfHead.addChild(Ear1);
Ear1.setTextureOffset(16, 14).addBox(-4.0F, -8.0F, -5.0F, 3.0F, 3.0F, 1.0F, 0.0F, true);
Ear2 = new ModelRenderer(this);
Ear2.setRotationPoint(0.0F, 0.0F, 0.0F);
WolfHead.addChild(Ear2);
Ear2.setTextureOffset(16, 14).addBox(1.0F, -8.0F, -5.0F, 3.0F, 3.0F, 1.0F, 0.0F, true);
Nose = new ModelRenderer(this);
Nose.setRotationPoint(0.5F, 0.0F, 0.0F);
WolfHead.addChild(Nose);
Nose.setTextureOffset(4, 14).addBox(-3.0F, -2.5F, -14.0F, 5.0F, 5.0F, 6.0F, 0.0F, true);
Body = new ModelRenderer(this);
Body.setRotationPoint(0.0F, 13.0F, 2.0F);
setRotationAngle(Body, 1.5708F, 0.0F, 0.0F);
Body.setTextureOffset(76, 4).addBox(-5.0F, -4.0F, -3.0F, 8.0F, 11.0F, 8.0F, 0.0F, true);
Mane = new ModelRenderer(this);
Mane.setRotationPoint(-1.0F, 14.0F, -3.0F);
setRotationAngle(Mane, 1.5708F, 0.0F, 0.0F);
Mane.setTextureOffset(27, 0).addBox(-5.0F, -6.0F, -2.0F, 10.0F, 7.0F, 9.0F, 0.0F, true);
Leg1 = new ModelRenderer(this);
Leg1.setRotationPoint(-3.5F, 16.0F, 7.0F);
Leg1.setTextureOffset(8, 27).addBox(-1.5F, 0.0F, -3.0F, 3.0F, 8.0F, 3.0F, 0.0F, true);
Leg2 = new ModelRenderer(this);
Leg2.setRotationPoint(1.5F, 16.0F, 7.0F);
Leg2.setTextureOffset(40, 9).addBox(-1.5F, 0.0F, -3.0F, 3.0F, 8.0F, 3.0F, 0.0F, true);
Leg3 = new ModelRenderer(this);
Leg3.setRotationPoint(-3.5F, 16.0F, -5.0F);
Leg3.setTextureOffset(39, 22).addBox(-1.5F, 0.0F, -2.0F, 3.0F, 8.0F, 3.0F, 0.0F, true);
Leg4 = new ModelRenderer(this);
Leg4.setRotationPoint(1.5F, 16.0F, -5.0F);
Leg4.setTextureOffset(0, 26).addBox(-1.5F, 0.0F, -2.0F, 3.0F, 8.0F, 3.0F, 0.0F, true);
Tail = new ModelRenderer(this);
Tail.setRotationPoint(-1.0F, 12.0F, 8.0F);
setRotationAngle(Tail, 1.1301F, 0.0F, 0.0F);
Tail.setTextureOffset(38, 19).addBox(-2.0F, 0.0F, -1.0F, 4.0F, 8.0F, 4.0F, 0.0F, true);
Tail.setTextureOffset(43, 21).addBox(-1.5F, 5.7133F, -0.7202F, 3.0F, 8.0F, 2.0F, 0.0F, true);
}
@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){
WolfHead.render(matrixStack, buffer, packedLight, packedOverlay);
Body.render(matrixStack, buffer, packedLight, packedOverlay);
Mane.render(matrixStack, buffer, packedLight, packedOverlay);
Leg1.render(matrixStack, buffer, packedLight, packedOverlay);
Leg2.render(matrixStack, buffer, packedLight, packedOverlay);
Leg3.render(matrixStack, buffer, packedLight, packedOverlay);
Leg4.render(matrixStack, buffer, packedLight, packedOverlay);
Tail.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;
}
}
Ahznb, maybe you should send some of that code to Klemen on the feature request ticket for scaling mobs, as it might help him add it faster :)
actually this is not the most efficient way to scale a mob. Op actually got it right the 1st time by overriding preRenderCallback in the entity's renderer class. thats the simplest way to do it. it was just that back then we didnt know how to use the gl matrix scale functions for 1.15.x. i'm sure Klemen knows the best way to do it, this is basic stuff to him.
Anyone help me ? :((
Here, you put it Here
@Override
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){
ms.push();
ms.scale(0.7f, 0.7f, 0.7f);
ms.translate(0F, 0.65F, 0F); // translation
WolfHead.render(matrixStack, buffer, packedLight, packedOverlay);
Body.render(matrixStack, buffer, packedLight, packedOverlay);
Mane.render(matrixStack, buffer, packedLight, packedOverlay);
Leg1.render(matrixStack, buffer, packedLight, packedOverlay);
Leg2.render(matrixStack, buffer, packedLight, packedOverlay);
Leg3.render(matrixStack, buffer, packedLight, packedOverlay);
Leg4.render(matrixStack, buffer, packedLight, packedOverlay);
Tail.render(matrixStack, buffer, packedLight, packedOverlay);
ms.pop();
}
before? makes any difference?
put it before the scaling code and use that formula i gave you, like this:
then all you need to do is change the scale variable for you entities, the rest is copy paste
cool i will use that formula thanks!
can you give me a hand with the child thing? i dont know where to start on that one, cause i use to do different on 1.12.
I dont know why but it's not working :((
This is what I did :
@Override
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
float alpha) {
ms.push();
ms.scale(0.7f, 0.7f, 0.7f);
ms.translate(0F, 0.65F, 0F);
WolfHead.render(matrixStack, buffer, packedLight, packedOverlay);
Body.render(matrixStack, buffer, packedLight, packedOverlay);
Mane.render(matrixStack, buffer, packedLight, packedOverlay);
Leg1.render(matrixStack, buffer, packedLight, packedOverlay);
Leg2.render(matrixStack, buffer, packedLight, packedOverlay);
Leg3.render(matrixStack, buffer, packedLight, packedOverlay);
Leg4.render(matrixStack, buffer, packedLight, packedOverlay);
Tail.render(matrixStack, buffer, packedLight, packedOverlay);
ms.pop();
}
And this is what it said :
Executing Gradle task: runClient
Build info: MCreator 2020.3.22116, forge-1.15.2, 64-bit, 4020 MB, Windows 8.1, JVM 1.8.0_252, JAVA_HOME: C:\Program Files\Pylo\MCreator\jdk
> Configure project :
New Dep: net.minecraftforge:forge:1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1
> Task :compileJava FAILED
C:\Users\MinhEragon\MCreatorWorkspaces\testonly\src\main\java\net\mcreator\testonly\entity\EdedEntity.java:203: error: cannot find symbol ms.push();
^
symbol: variable ms
location: class ModelDireWolv
C:\Users\MinhEragon\MCreatorWorkspaces\testonly\src\main\java\net\mcreator\testonly\entity\EdedEntity.java:204: error: cannot find symbol ms.scale(0.7f, 0.7f, 0.7f);
^
symbol: variable ms
location: class ModelDireWolv
C:\Users\MinhEragon\MCreatorWorkspaces\testonly\src\main\java\net\mcreator\testonly\entity\EdedEntity.java:205: error: cannot find symbol ms.translate(0F, 0.65F, 0F);
^
symbol: variable ms
location: class ModelDireWolv
C:\Users\MinhEragon\MCreatorWorkspaces\testonly\src\main\java\net\mcreator\testonly\entity\EdedEntity.java:216: error: cannot find symbol ms.pop();
^
symbol: variable ms
location: class ModelDireWolv
4 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.3/userguide/command_line_interface.html#se…
BUILD FAILED in 8s
1 actionable task: 1 executed
BUILD FAILED
Task completed in 12766 milliseconds
I tried like what ahznb said but still the same
did you import all the classes you need? also you doing for 1.15 right?
Hmm, what classes ? Yes I did it in 1.15
This is my first time so, can you tell me everything I need to do please
Here is the code :
package net.mcreator.testonly.entity;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.fml.network.FMLPlayMessages;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
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.World;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.DamageSource;
import net.minecraft.item.SpawnEggItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.Item;
import net.minecraft.entity.monster.MonsterEntity;
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.SharedMonsterAttributes;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.Entity;
import net.minecraft.entity.CreatureAttribute;
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.testonly.TestonlyModElements;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.mojang.blaze3d.matrix.MatrixStack;
@TestonlyModElements.ModElement.Tag
public class EdedEntity extends TestonlyModElements.ModElement {
public static EntityType entity = null;
public EdedEntity(TestonlyModElements instance) {
super(instance, 28);
FMLJavaModLoadingContext.get().getModEventBus().register(this);
}
@Override
public void initElements() {
entity = (EntityType.Builder.<CustomEntity>create(CustomEntity::new, EntityClassification.MONSTER).setShouldReceiveVelocityUpdates(true)
.setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(CustomEntity::new).size(0.6f, 1.8f)).build("eded")
.setRegistryName("eded");
elements.entities.add(() -> entity);
elements.items.add(() -> new SpawnEggItem(entity, -1, -1, new Item.Properties().group(ItemGroup.MISC)).setRegistryName("eded"));
}
@SubscribeEvent
@OnlyIn(Dist.CLIENT)
public void registerModels(ModelRegistryEvent event) {
RenderingRegistry.registerEntityRenderingHandler(entity, renderManager -> {
return new MobRenderer(renderManager, new ModelDireWolv(), 0.5f) {
@Override
public ResourceLocation getEntityTexture(Entity entity) {
return new ResourceLocation("testonly:textures/direwolf.png");
}
};
});
}
public static class CustomEntity extends MonsterEntity {
public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
this(entity, world);
}
public CustomEntity(EntityType<CustomEntity> type, World world) {
super(type, world);
experienceValue = 0;
setNoAI(false);
enablePersistence();
}
@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));
}
@Override
public CreatureAttribute getCreatureAttribute() {
return CreatureAttribute.UNDEFINED;
}
@Override
public boolean canDespawn(double distanceToClosestPlayer) {
return false;
}
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("block.anvil.land"));
}
@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);
}
}
// 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 ModelDireWolv extends EntityModel<Entity> {
private final ModelRenderer WolfHead;
private final ModelRenderer Ear1;
private final ModelRenderer Ear2;
private final ModelRenderer Nose;
private final ModelRenderer Body;
private final ModelRenderer Mane;
private final ModelRenderer Leg1;
private final ModelRenderer Leg2;
private final ModelRenderer Leg3;
private final ModelRenderer Leg4;
private final ModelRenderer Tail;
public ModelDireWolv() {
textureWidth = 128;
textureHeight = 64;
WolfHead = new ModelRenderer(this);
WolfHead.setRotationPoint(-1.0F, 13.5F, -7.0F);
WolfHead.setTextureOffset(2, 0).addBox(-4.0F, -5.5F, -8.0F, 8.0F, 8.0F, 6.0F, 0.0F, true);
Ear1 = new ModelRenderer(this);
Ear1.setRotationPoint(0.0F, 0.0F, 0.0F);
WolfHead.addChild(Ear1);
Ear1.setTextureOffset(16, 14).addBox(-4.0F, -8.0F, -5.0F, 3.0F, 3.0F, 1.0F, 0.0F, true);
Ear2 = new ModelRenderer(this);
Ear2.setRotationPoint(0.0F, 0.0F, 0.0F);
WolfHead.addChild(Ear2);
Ear2.setTextureOffset(16, 14).addBox(1.0F, -8.0F, -5.0F, 3.0F, 3.0F, 1.0F, 0.0F, true);
Nose = new ModelRenderer(this);
Nose.setRotationPoint(0.5F, 0.0F, 0.0F);
WolfHead.addChild(Nose);
Nose.setTextureOffset(4, 14).addBox(-3.0F, -2.5F, -14.0F, 5.0F, 5.0F, 6.0F, 0.0F, true);
Body = new ModelRenderer(this);
Body.setRotationPoint(0.0F, 13.0F, 2.0F);
setRotationAngle(Body, 1.5708F, 0.0F, 0.0F);
Body.setTextureOffset(76, 4).addBox(-5.0F, -4.0F, -3.0F, 8.0F, 11.0F, 8.0F, 0.0F, true);
Mane = new ModelRenderer(this);
Mane.setRotationPoint(-1.0F, 14.0F, -3.0F);
setRotationAngle(Mane, 1.5708F, 0.0F, 0.0F);
Mane.setTextureOffset(27, 0).addBox(-5.0F, -6.0F, -2.0F, 10.0F, 7.0F, 9.0F, 0.0F, true);
Leg1 = new ModelRenderer(this);
Leg1.setRotationPoint(-3.5F, 16.0F, 7.0F);
Leg1.setTextureOffset(8, 27).addBox(-1.5F, 0.0F, -3.0F, 3.0F, 8.0F, 3.0F, 0.0F, true);
Leg2 = new ModelRenderer(this);
Leg2.setRotationPoint(1.5F, 16.0F, 7.0F);
Leg2.setTextureOffset(40, 9).addBox(-1.5F, 0.0F, -3.0F, 3.0F, 8.0F, 3.0F, 0.0F, true);
Leg3 = new ModelRenderer(this);
Leg3.setRotationPoint(-3.5F, 16.0F, -5.0F);
Leg3.setTextureOffset(39, 22).addBox(-1.5F, 0.0F, -2.0F, 3.0F, 8.0F, 3.0F, 0.0F, true);
Leg4 = new ModelRenderer(this);
Leg4.setRotationPoint(1.5F, 16.0F, -5.0F);
Leg4.setTextureOffset(0, 26).addBox(-1.5F, 0.0F, -2.0F, 3.0F, 8.0F, 3.0F, 0.0F, true);
Tail = new ModelRenderer(this);
Tail.setRotationPoint(-1.0F, 12.0F, 8.0F);
setRotationAngle(Tail, 1.1301F, 0.0F, 0.0F);
Tail.setTextureOffset(38, 19).addBox(-2.0F, 0.0F, -1.0F, 4.0F, 8.0F, 4.0F, 0.0F, true);
Tail.setTextureOffset(43, 21).addBox(-1.5F, 5.7133F, -0.7202F, 3.0F, 8.0F, 2.0F, 0.0F, true);
}
@Override
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
float alpha) {
WolfHead.render(matrixStack, buffer, packedLight, packedOverlay);
Body.render(matrixStack, buffer, packedLight, packedOverlay);
Mane.render(matrixStack, buffer, packedLight, packedOverlay);
Leg1.render(matrixStack, buffer, packedLight, packedOverlay);
Leg2.render(matrixStack, buffer, packedLight, packedOverlay);
Leg3.render(matrixStack, buffer, packedLight, packedOverlay);
Leg4.render(matrixStack, buffer, packedLight, packedOverlay);
Tail.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) {
}
}
}