Scale a Mob on the Code

Started by gustavowizard123 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Scale a Mob on the Code

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!

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
yes i realise that, but i…
Tue, 06/09/2020 - 22:01

yes i realise that, but i cant find the information anywhere :( the new commands and functions.. i need the scale thing for mobs

Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
there's a render method in…
Wed, 06/10/2020 - 08:12

there's a render method in the models class.put your GlStateManager.scale functions there

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
can you point me where here…
Wed, 06/10/2020 - 23:57

can you point me where here please? im new on java yet :(

 

@WizardAnimalsPlusModElements.ModElement.Tag
public class ButterflyRedAgriasEntity extends WizardAnimalsPlusModElements.ModElement {
	public static EntityType entity = null;
	public ButterflyRedAgriasEntity(WizardAnimalsPlusModElements instance) {
		super(instance, 3);
		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.5f, 0.5f)).build("butterfly_red_agrias")
						.setRegistryName("butterfly_red_agrias");
		elements.entities.add(() -> entity);
		elements.items.add(() -> new SpawnEggItem(entity, -65485, -14869990, new Item.Properties().group(ItemGroup.MISC))
				.setRegistryName("butterfly_red_agrias"));
	}

	@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 (ForgeRegistries.BIOMES.getKey(biome).equals(new ResourceLocation("jungle_edge")))
				biomeCriteria = true;
			if (!biomeCriteria)
				continue;
			biome.getSpawns(EntityClassification.CREATURE).add(new Biome.SpawnListEntry(entity, 10, 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 ModelButterfly(), 0.2f) {
				@Override
				public ResourceLocation getEntityTexture(Entity entity) {
					return new ResourceLocation("wizard_animals_plus:textures/butterfly_agriasclaudina.png");
				}

				//protected void preRenderCallback(BatEntity entitylivingbaseIn, float partialTickTime) 
				//{
					//float f = 1.0F;
					//GL11.glScalef(0.2F, 0.2F, 0.2F);
					//RenderSystem.scalef(0.2F, 0.2F, 0.2F);
					//GlStateManager.scale(0.25f, 0.25f, 0.25f);
					
				
				//}
				
				 
		

			
		};		
				
		});
				
   				 	
	}

	public static class CustomEntity extends BatEntity {
		public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
			this(entity, world);
		}

		public CustomEntity(EntityType<CustomEntity> type, World world) {
			super(type, world);
			experienceValue = 0;
			setNoAI(false);
			this.moveController = new FlyingMovementController(this, 10, true);
			this.navigator = new FlyingPathNavigator(this, this.world);
		}

		@Override
		public EntitySize getSize(Pose poseIn) {
        	return super.getSize(poseIn).scale(0.5F, 0.5F);
    	}	

		@Override
		protected void registerGoals() {
			super.registerGoals();
		}

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

		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
		public boolean onLivingFall(float l, float d) {
			return false;
		}

		@Override
		protected void registerAttributes() {
			super.registerAttributes();
			if (this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED) != null)
				this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.5);
			if (this.getAttribute(SharedMonsterAttributes.MAX_HEALTH) != null)
				this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(1);
			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);
			if (this.getAttribute(SharedMonsterAttributes.FLYING_SPEED) == null)
				this.getAttributes().registerAttribute(SharedMonsterAttributes.FLYING_SPEED);
			this.getAttribute(SharedMonsterAttributes.FLYING_SPEED).setBaseValue(0.5);
		}

		@Override
		protected void updateFallState(double y, boolean onGroundIn, BlockState state, BlockPos pos) {
		}

		@Override
		public void setNoGravity(boolean ignored) {
			super.setNoGravity(true);
		}

		public void livingTick() {
			super.livingTick();
			this.setNoGravity(true);
		}
	}

	// Date: 27/11/2017 14:49:42
	// Template version 1.1
	// Java generated by Techne
	// Keep in mind that you still need to fill in some blanks
	// - ZeuX
	public static class ModelButterfly extends EntityModel<Entity> {
		// fields
		ModelRenderer body;
		ModelRenderer RightWing;
		ModelRenderer LeftWing;
		ModelRenderer Antenas;
		ModelRenderer Head;
		public ModelButterfly() {
			textureWidth = 64;
			textureHeight = 64;
			body = new ModelRenderer(this, 4, 4);
			body.addBox(-1F, -1F, -4F, 2, 2, 9);
			body.setRotationPoint(0F, 22F, 0F);
			body.setTextureSize(64, 64);
			body.mirror = true;
			setRotation(body, 0F, 0F, 0F);
			RightWing = new ModelRenderer(this, 4, 28);
			RightWing.addBox(-12F, 0F, -6F, 12, 0, 16);
			RightWing.setRotationPoint(0F, 22F, -2F);
			RightWing.setTextureSize(64, 64);
			RightWing.mirror = true;
			setRotation(RightWing, 0F, 0F, 0F);
			LeftWing = new ModelRenderer(this, 4, 46);
			LeftWing.addBox(0F, 0F, -6F, 12, 0, 16);
			LeftWing.setRotationPoint(0F, 22F, -2F);
			LeftWing.setTextureSize(64, 64);
			LeftWing.mirror = true;
			setRotation(LeftWing, 0F, 0F, 0F);
			Antenas = new ModelRenderer(this, 4, 17);
			Antenas.addBox(-4.5F, 0F, -9F, 9, 0, 9);
			Antenas.setRotationPoint(0F, 22F, -5F);
			Antenas.setTextureSize(64, 64);
			Antenas.mirror = true;
			setRotation(Antenas, -0.1745329F, 0F, 0F);
			Head = new ModelRenderer(this, 31, 5);
			Head.addBox(-1.5F, -1F, -1.5F, 3, 3, 3);
			Head.setRotationPoint(0F, 22F, -5F);
			Head.setTextureSize(64, 64);
			Head.mirror = true;
			setRotation(Head, 0F, 0F, 0F);
		}

		public void render(MatrixStack ms, IVertexBuilder vb, int i1, int i2, float f1, float f2, float f3, float f4) {
			body.render(ms, vb, i1, i2, f1, f2, f3, f4);
			RightWing.render(ms, vb, i1, i2, f1, f2, f3, f4);
			LeftWing.render(ms, vb, i1, i2, f1, f2, f3, f4);
			Antenas.render(ms, vb, i1, i2, f1, f2, f3, f4);
			Head.render(ms, vb, i1, i2, f1, f2, f3, f4);
		}

		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.RightWing.rotateAngleZ = MathHelper.cos(f * 1F) * 1.4F * f1;
			this.LeftWing.rotateAngleZ = MathHelper.cos(f * 1F + (float) Math.PI) * 1.4F * f1;
		}

 

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
thats the mob entire code…
Thu, 06/11/2020 - 00:00

thats the mob entire code there.. thank you btw!

Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
in your ModelButterfly class…
Thu, 06/11/2020 - 20:30

in your ModelButterfly class there's a render method right above the setRotation method. try doing something like this:

public void render(MatrixStack ms, IVertexBuilder vb, int i1, int i2, float f1, float f2, float f3, float f4) {
    GlStateManager.pushMatrix();
    GlStateManager.scale(0.25f, 0.25f, 0.25f);

    body.render(ms, vb, i1, i2, f1, f2, f3, f4);
    RightWing.render(ms, vb, i1, i2, f1, f2, f3, f4);
    LeftWing.render(ms, vb, i1, i2, f1, f2, f3, f4);
    Antenas.render(ms, vb, i1, i2, f1, f2, f3, f4);
    Head.render(ms, vb, i1, i2, f1, f2, f3, f4);

    GlStateManager.popMatrix();
}

but i have to warn you i'm not familiar with 1.15.x, like i dont know what MatrixStack is, so you will need to test it on your own.

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
just tried but all those…
Thu, 06/11/2020 - 21:23

just tried but all those GlStateManager functions dont exist on MC 1.15,

not even the entry

import net.minecraft.client.renderer.GlStateManager

will be acepted :(

Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
i just looked up MatrixStack…
Fri, 06/12/2020 - 01:59

i just looked up MatrixStack info on the web, seems the push/pop/scale functions are all in MatrixStack in 1.15x. use the following instead:

ms.push();
ms.scale(0.25f, 0.25f, 0.25f);
...
ms.pop();

 

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
omg thank you so much it…
Fri, 06/12/2020 - 02:49

omg thank you so much it actually worked!

:D

Now all i need is make the child breed thing and the taming code; you said you make a new file for the childs right? how do you make the mob breed a different mob in the code?

thanks again!

Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
no that wasn't me, i'm not…
Fri, 06/12/2020 - 03:07

no that wasn't me, i'm not familiar with mc breeding mechanics yet. but if the child is still the same entity class then you code it in the same entity class. look at what vanilla mc does with villagers or zombies.

you could try searching on minecraftforge.net if you're gonna jump deep down the coding path.

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
ah cool... hey the scale…
Fri, 06/12/2020 - 03:40

ah cool...

hey the scale thing worked but the mob now spawn a little bit over the ground (floating), i know i have to change the Z offset someplace now, not sure how thou

Joined Jun 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sorry, about the ms.push…
Fri, 06/12/2020 - 04:12

Sorry, about the ms.push/scale/pop, I dont know where to put it ?

This is mine : 

public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
                float alpha) {
            All.render(matrixStack, buffer, packedLight, packedOverlay);
        }

Should I do this? <I wont work tho>

public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
                float alpha) {
            ms.push();
            ms.scale(0.25f, 0.25f, 0.25f);
            ms.pop();
            
            All.render(matrixStack, buffer, packedLight, packedOverlay);
        }

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
you put here, at the end,…
Fri, 06/12/2020 - 04:16

you put here, at the end, above the animations

 

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

			ms.push();
			ms.scale(0.7f, 0.7f, 0.7f);
			ms.translate(0F, -0.0625F, 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();
		}

 

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
nvm the translate part for…
Fri, 06/12/2020 - 04:17

nvm the translate part for now, im still trying to figger how to make the mob spawn on the floor and not floating... it de-scale but not from the floor it seams

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
yes i fix it with that…
Fri, 06/12/2020 - 04:29

yes i fix it with that translate call, you need to set a positive value to push the spawn down; so for a mob scaled to 70% like the one above i use

ms.translate(0F, 0.7F, 0F); // translation