Minecraft stops working after creating a custom mob

Started by Sheeshily on

Topic category: Troubleshooting, bugs, and solutions

Last seen on 19:39, 20. Oct 2019
Joined Oct 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Minecraft stops working after creating a custom mob

After I created and ran the gradle build several times successfully and the test Minecraft server and Minecraft itself booted up, everytime after I connected to the server, the game just stands still after some seconds. (OpenJDK doesnt response it shows after trying to close the frozen Minecraft). The execption I get from the server isn't helpful at all, since it just tells me that the active socket connection got closed by the user. I don't know what the error could be for that, here's my java class:

@Elementsdesertmod.ModElement.Tag
public class MCreatorScarab extends Elementsdesertmod.ModElement {
	public static final int ENTITYID = 1;
	public static final int ENTITYID_RANGED = 2;

	public MCreatorScarab(Elementsdesertmod instance) {
		super(instance, 1);
	}

	@Override
	public void initElements() {
		elements.entities.add(() -> EntityEntryBuilder.create().entity(EntityCustom.class).id(new ResourceLocation("desertmod", "scarab"), ENTITYID)
				.name("scarab").tracker(64, 1, true).egg(-13369549, -65332).build());
	}

	@Override
	public void init(FMLInitializationEvent event) {
		Biome[] spawnBiomes = {Biome.REGISTRY.getObject(new ResourceLocation("desert")), Biome.REGISTRY.getObject(new ResourceLocation("plains")),
				Biome.REGISTRY.getObject(new ResourceLocation("hell")), Biome.REGISTRY.getObject(new ResourceLocation("mutated_desert")),
				Biome.REGISTRY.getObject(new ResourceLocation("stone_beach")), Biome.REGISTRY.getObject(new ResourceLocation("desert_hills")),
				Biome.REGISTRY.getObject(new ResourceLocation("beaches")), Biome.REGISTRY.getObject(new ResourceLocation("savanna")),};
		EntityRegistry.addSpawn(EntityCustom.class, 10, 6, 54, EnumCreatureType.MONSTER, spawnBiomes);
	}

	@SideOnly(Side.CLIENT)
	@Override
	public void preInit(FMLPreInitializationEvent event) {
		RenderingRegistry.registerEntityRenderingHandler(EntityCustom.class, renderManager -> {
			RenderLiving customRender = new RenderLiving(renderManager, new ModelSilverfish(), 0.5f) {
				protected ResourceLocation getEntityTexture(Entity entity) {
					return new ResourceLocation("desertmod:textures/silverfish.png");
				}
			};
			customRender.addLayer(new net.minecraft.client.renderer.entity.layers.LayerHeldItem(customRender));
			return customRender;
		});
	}

	public static class EntityCustom extends EntityAnimal {
		public EntityCustom(World world) {
			super(world);
			setSize(0.4f, 0.3f);
			experienceValue = 2;
			this.isImmuneToFire = false;
			setNoAI(!true);
			this.tasks.addTask(1, new EntityAILookIdle(this));
			this.tasks.addTask(2, new EntityAIWander(this, 0.8));
			this.tasks.addTask(3, new EntityAISwimming(this));
			this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.2, true));
			this.targetTasks.addTask(5, new EntityAINearestAttackableTarget(this, EntityChicken.class, true, true));
			this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityChicken.class, (float) 20));
			this.tasks.addTask(7, new EntityAIBreakDoor(this));
			this.tasks.addTask(8, new EntityAIEatGrass(this));
			this.tasks.addTask(3, new EntityAIMate(this, 1.0D));
		}

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

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

		@Override
		public net.minecraft.util.SoundEvent getAmbientSound() {
			return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation(
					"desertmod:desertmod.entity.scarab.step"));
		}

		@Override
		public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
			return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation(
					"desertmod:desertmod.entity.scarab.hurt"));
		}

		@Override
		public net.minecraft.util.SoundEvent getDeathSound() {
			return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation(
					"desertmod:desertmod.entity.scarab.death"));
		}

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

		@Override
		public boolean attackEntityFrom(DamageSource source, float amount) {
			if (source.getImmediateSource() instanceof EntityArrow)
				return false;
			if (source == DamageSource.DROWN)
				return false;
			return super.attackEntityFrom(source, amount);
		}

		@Override
		protected void applyEntityAttributes() {
			super.applyEntityAttributes();
			if (this.getEntityAttribute(SharedMonsterAttributes.ARMOR) != null)
				this.getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(0D);
			if (this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED) != null)
				this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.3D);
			if (this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH) != null)
				this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(2D);
			if (this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) != null)
				this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(1D);
		}

		@Override
		public EntityCustom createChild(EntityAgeable ageable) {
			return new EntityCustom(world);
		}

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

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

 

Please paste the whole crash…
Sun, 10/13/2019 - 10:38

Please paste the whole crash log from the server here, otherwise, it will be just guessing.

Last seen on 19:39, 20. Oct 2019
Joined Oct 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Solved, it were the sounds…
Sun, 10/13/2019 - 13:52

Solved, it were the sounds somehow.