Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I created a Boar mob and tried to make a Monster Spawner via command that spawns my mob.

First I tried with /give @p mob_spawner 1 0 {BlockEntityTag:{EntityId:Skeleton}}. It gave me the basic spawner block which spawns

pigs.

After that I used /setblock ~ ~ ~ mob_spawner 0 destroy {EntityId:Boar}. It spawned the block with the little spinning boar with it,

but spawned nothing.

 

Is the problem in the code or I search somewhere else?

Just to be sure here is my Boar.class

 

package net.Aethoscraft.mod.entity.hostile;

import java.util.Random;

import net.Aethoscraft.mod.Aethoscraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.boss.IBossDisplayData;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.world.World;

public class EntityBoar extends EntityMob implements IBossDisplayData {

 Random r = new Random();

public EntityBoar(World world) {
	super(world);
	this.experienceValue = 2;

	this.tasks.addTask(0, new EntityAIWatchClosest(this, EntityPlayer.class, 5.0F));
	this.targetTasks.addTask(0, new EntityAIHurtByTarget(this, true));
	this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));

	this.setCustomNameTag("Boar");

}

 protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(5.0D);
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.3D);
        this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(1.5D);
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(40.0D);
    }

 public boolean attackEntityAsMob(Entity p_70652_1_)
    {
	 	return true;
    }

 protected boolean isAIEnabled()
    {
        return true;
    }

 protected Item getDropItem()
    {
        if(r.nextInt(100)>20)
        	return Items.leather;
        else
        	return Aethoscraft.itemBoarTusk;


    } 
}

 

  • Author

package net.Aethoscraft.mod.handlers;

import java.util.Random;

import net.Aethoscraft.mod.Aethoscraft;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityList.EntityEggInfo;
import net.minecraft.entity.EnumCreatureType;
import cpw.mods.fml.common.registry.EntityRegistry;

public class EntityHandler {

public static void registerMonsters(Class entityClass, String name){

	int entityID = EntityRegistry.findGlobalUniqueEntityId();
	long x = name.hashCode();
	Random random = new Random(x);
	int mainColor = random.nextInt() * 16777215;
	int subColor = random.nextInt() * 16777215;

	EntityRegistry.registerGlobalEntityID(entityClass, name, entityID);
	EntityRegistry.addSpawn(entityClass, 50, 2, 4,EnumCreatureType.monster);
	EntityRegistry.registerModEntity(entityClass, name, entityID, Aethoscraft.instance, 16, 1, true);
	EntityList.entityEggs.put(Integer.valueOf(entityID),new EntityList.EntityEggInfo(entityID, mainColor,subColor));

}

public static void registerCreatures(Class entityClass, String name){

	int entityID = EntityRegistry.findGlobalUniqueEntityId();
	long x = name.hashCode();
	Random random = new Random(x);
	int mainColor = random.nextInt() * 16777215;
	int subColor = random.nextInt() * 16777215;

	EntityRegistry.registerGlobalEntityID(entityClass, name, entityID);
	EntityRegistry.addSpawn(entityClass, 50, 2, 4,EnumCreatureType.creature);
	EntityRegistry.registerModEntity(entityClass, name, entityID, Aethoscraft.instance, 16, 1, true);
	EntityList.entityEggs.put(Integer.valueOf(entityID),new EntityList.EntityEggInfo(entityID, mainColor,subColor));

}

}

 

In the main mod class I simply call the handler class above:

EntityHandler.registerMonsters(EntityBoar.class, "Boar");

  • Author

Can u give me a good tutorial on how to avoid global entity IDs (i know that global IDs can only store 256 entities)?I mean that I wish to use custom IDs and if I'm not mistaken, spawn eggs don't work with custom IDs.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.