MCreator freeze when Render Scaled Flying Mob

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:
MCreator freeze when Render Scaled Flying Mob

Ok so this horrible error happens when i spawn this butterfly on the enviroment test world, i cant even copy the error because Mcreator Totally freezes, so i take a picture:

 

https://s19.postimg.org/okacucxkj/error.jpg

 

package mod.mcreator;

import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.client.registry.RenderingRegistry;

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.EnumHand;
import net.minecraft.util.DamageSource;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item;
import net.minecraft.init.Items;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.passive.EntityBat;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.Entity;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.Minecraft;

import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.EntityAgeable;

import java.util.Random;
import java.util.Iterator;
import java.util.ArrayList;

@SuppressWarnings("unchecked")
public class mcreator_butterflyMonarch {

	public int mobid = 0;
	public static Object instance;

	public void load(FMLInitializationEvent event) {
	}

	public void generateNether(World world, Random random, int chunkX, int chunkZ) {
	}

	public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
	}

	public int addFuel(ItemStack fuel) {
		return 0;
	}

	


    @SideOnly(Side.CLIENT)
     public void registerRenderers() {
          RenderLiving customRender = new RenderLiving<EntityAgeable>(Minecraft.getMinecraft().getRenderManager(), new mcreator_butterflyMonarch.ModelButterfly(), 0) {
     
     protected ResourceLocation getEntityTexture(EntityAgeable par1Entity) {
          return new ResourceLocation("t1.png");
     }
     
     protected void preRenderCallback(EntityAgeable entitylivingbaseIn, float partialTickTime) {
          float f = 0.2F;
          if (entitylivingbaseIn.getGrowingAge() < 0) {
               f = (float)((double)f * 0.5D);
               this.shadowSize = 0.25F;
          } else {
               this.shadowSize = 0.5F;
          }
          GlStateManager.scale(f, f, f);
     }    
     
};
          RenderingRegistry.registerEntityRenderingHandler(mcreator_butterflyMonarch.EntitybutterflyMonarch.class, customRender);

     }

	public void serverLoad(FMLServerStartingEvent event) {
	}

	public void preInit(FMLPreInitializationEvent event) {
		int entityID = MathHelper.getRandomUUID().hashCode();
		mobid = entityID;
		EntityRegistry.registerModEntity(mcreator_butterflyMonarch.EntitybutterflyMonarch.class, "butterflyMonarch", entityID, instance, 64, 1, true,
				(0 << 16) + (0 << 8) + 0, (255 << 16) + (153 << 8) + 51);
		EntityRegistry.addSpawn(mcreator_butterflyMonarch.EntitybutterflyMonarch.class, 20, 5, 10, EnumCreatureType.CREATURE,
				Biome.REGISTRY.getObject(new ResourceLocation("forest")));

	}

	public static Biome[] clean(net.minecraft.util.registry.RegistryNamespaced<ResourceLocation, Biome> in) {
		Iterator<Biome> itr = in.iterator();
		ArrayList<Biome> ls = new ArrayList<Biome>();
		while (itr.hasNext()) {
			ls.add(itr.next());
		}
		return ls.toArray(new Biome[ls.size()]);
	}

	public static class EntitybutterflyMonarch extends EntityBat {
		World world = null;

		public EntitybutterflyMonarch(World var1) {
			super(var1);
			world = var1;
			experienceValue = 1;
			this.isImmuneToFire = false;
			addRandomArmor();
			setNoAI(!true);
			//this.tasks.addTask(0, new EntityAISwimming(this));
			//this.tasks.addTask(6, new EntityAIWander(this, 1.0D));
			//this.tasks.addTask(8, new EntityAILookIdle(this));

		}

		protected void addRandomArmor() {

		}

         public EntitybutterflyMonarch createChild(EntityAgeable ageable) {
           return new EntitybutterflyMonarch(world);
          }

          public float getEyeHeight() {
               return this.isChild() ? this.height : 1.3F;
          }

          public boolean isBreedingItem(ItemStack stack) {
               return stack != null && com.google.common.collect.Sets.newHashSet(new Item[]{Items.SUGAR,}).contains(stack.getItem());
          }

		protected void dropRareDrop(int par1) {
			this.dropItem(new ItemStack(Items.DYE, 1, 0).getItem(), 1);
		}

		@Override
		protected Item getDropItem() {
			return new ItemStack(Items.DYE, 1, 14).getItem();
		}

		@Override
		protected net.minecraft.util.SoundEvent getAmbientSound() {
			return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation(""));
		}

		@Override
		protected net.minecraft.util.SoundEvent getHurtSound() {
			return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("game.neutral.hurt"));
		}

		@Override
		protected net.minecraft.util.SoundEvent getDeathSound() {
			return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("game.neutral.die"));
		}

		@Override
		public void onStruckByLightning(EntityLightningBolt entityLightningBolt) {
			super.onStruckByLightning(entityLightningBolt);
			int i = (int) this.posX;
			int j = (int) this.posY;
			int k = (int) this.posZ;
			Entity entity = this;

		}

		@Override
		public void fall(float l, float d) {
			super.fall(l, d);
			int i = (int) this.posX;
			int j = (int) this.posY;
			int k = (int) this.posZ;
			super.fall(l, d);
			Entity entity = this;

		}

		@Override
		public void onDeath(DamageSource source) {
			super.onDeath(source);
			int i = (int) this.posX;
			int j = (int) this.posY;
			int k = (int) this.posZ;
			Entity entity = this;

		}

		@Override
		public boolean processInteract(EntityPlayer entity, EnumHand hand, ItemStack stack) {
			super.processInteract(entity, hand, stack);
			int i = (int) this.posX;
			int j = (int) this.posY;
			int k = (int) this.posZ;

			return true;
		}

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

	}

	// 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 ModelBase {
		// 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(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
			super.render(entity, f, f1, f2, f3, f4, f5);
			setRotationAngles(f, f1, f2, f3, f4, f5, entity);
			body.render(f5);
			RightWing.render(f5);
			LeftWing.render(f5);
			Antenas.render(f5);
			Head.render(f5);
		}

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

		public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) {
			super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
               this.RightWing.rotateAngleZ = MathHelper.cos(f * 0.6662F) * 1.4F * f1;
               this.LeftWing.rotateAngleZ = MathHelper.cos(f * 0.6662F + (float) Math.PI) * 1.4F * f1;
		}

	}

}

 

Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Your entity extends…
Tue, 11/28/2017 - 15:48

Your entity extends EntityBat, that is a child EntityAmbientCreature, however, you are casting it in your renderer to EntityAgeable

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
nvm that man, i made it by…
Tue, 11/28/2017 - 22:15

nvm that man, i made it by try and error and some luck lol, here is the code if someone need:

@SideOnly(Side.CLIENT)
     public void registerRenderers() {
          RenderLiving customRender = new RenderLiving<EntityBat>(Minecraft.getMinecraft().getRenderManager(), new mcreator_butterflyMonarch.ModelButterfly(), 0) {
     
     protected ResourceLocation getEntityTexture(EntityBat par1Entity) {
          return new ResourceLocation("t1.png");
     }
     
     protected void preRenderCallback(EntityBat entitylivingbaseIn, float partialTickTime) {
          float f = 1.0F;
         
          GlStateManager.scale(0.2f, 0.2f, 0.2f);
     }    
     
};
          RenderingRegistry.registerEntityRenderingHandler(mcreator_butterflyMonarch.EntitybutterflyMonarch.class, customRender);

     }