Jump to content

Recommended Posts

Posted (edited)

 

Started with 

 

Moving on from there

 

Going to create some entities!

  Reveal hidden contents

 

-new Package goat with class Entity_Goat

-new Startup Classes StartupDedicatedServer, StartupClientOnly, StartupCommon

-each with their respective 

public static void preInit<classname>()		{ }
public static void init<classname>()		{ }
public static void postInit<classname>()	{ }

 

Going to base a most of this code on EntitySheep

 

-Entity_Goat is going to extend EntityAnimal

  Reveal hidden contents

 

-create constructor with World input parameter and setSize of Entity_Goat

	public Entity_Goat(World worldIn) 
	{
		super(worldIn);
		this.setSize(1.2F, 1.7F);
	}

 

-give Entity_Goat ability to createChild which we can use to pass variable from parent to child later on

	@Override
	public Entity_Goat createChild(EntityAgeable ageable) 
	{
		Entity_Goat entitygoat1 = new Entity_Goat(this.world);
		return entitygoat1;
	}

 

-give Entity_Goat attributes, an initialization function and an on first spawn function

    protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(14.0D);
        this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.3D);
    }

    protected void entityInit()
    {
        super.entityInit();
    }    
	@Nullable
    public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata)
    {
        livingdata = super.onInitialSpawn(difficulty, livingdata);
        return livingdata;
    }

 

  Reveal hidden contents

 

-set up register functions for entity in main mod class

	public static int startEntityID;
    public static int i;

	public static void registerModEntity(Class<? extends Entity> entityClass, String name) {
		EntityRegistry.registerModEntity(new ResourceLocation("class:resources"), entityClass, name, ++startEntityID, Ascension.instance, 80, 3, false);
      //Unsure about new ResourceLocation("class:resources") -Gotlyfe
		logger.info("Registering mod entity " + name + " with ID = " + startEntityID);
	}

	public static void registerModEntityEgg(Class<? extends Entity> entityClass, String name, int primary, int secondary) {
		registerModEntity(entityClass, name);

		if (i == 0) {
			registerSpawnEgg(name, primary, secondary);
			++i;
		}
	}

	public static void registerSpawnEgg(String name, int primary, int secondary) {

	}

	public static int getUniqueEntityId() {
		do {
			startEntityID++;
		} while (EntityList.getClassFromID(startEntityID) != null);
      //EntityList.getStringFromID() No longer exists but .getClassFromID() functions similarly in this case - Gotlyfe

		return startEntityID;
	}
  Reveal hidden contents

 

 

Edited by Gotlyfe

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...

  Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

  Your link has been automatically embedded.   Display as a link instead

  Your previous content has been restored.   Clear editor

  You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Create New...

Important Information

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