Jump to content

Recommended Posts

Posted (edited)

 

Started with 

 

Moving on from there

 

Going to create some entities!

Spoiler

References thus far:

A lot of reading the EntitySheep.class and seeing where it's referenced inside forgedSrc
TheXFactor117 's Forge 1.7 Modding Tutorials

 

-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

Spoiler

requires


import net.minecraft.entity.passive.EntityAnimal;

which requires constructor, auto generated as


	public Entity_Goat(World worldIn) 
    {	super(worldIn);		}

and override function createChild, auto generated as


	@Override
	public EntityAgeable createChild(EntityAgeable ageable) 
	{	return null;	}

 

which require


import net.minecraft.entity.EntityAgeable;
import net.minecraft.world.World;

 

 

-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;
    }

 

Spoiler

attributes from SharedMonsterAttributes.class


 private static final Logger LOGGER = LogManager.getLogger();
    public static final IAttribute MAX_HEALTH = (new RangedAttribute((IAttribute)null, "generic.maxHealth", 20.0D, Float.MIN_VALUE, 1024.0D)).setDescription("Max Health").setShouldWatch(true); // Forge: set smallest max-health value to fix MC-119183. This gets rounded to float so we use the smallest positive float value.
    public static final IAttribute FOLLOW_RANGE = (new RangedAttribute((IAttribute)null, "generic.followRange", 32.0D, 0.0D, 2048.0D)).setDescription("Follow Range");
    public static final IAttribute KNOCKBACK_RESISTANCE = (new RangedAttribute((IAttribute)null, "generic.knockbackResistance", 0.0D, 0.0D, 1.0D)).setDescription("Knockback Resistance");
    public static final IAttribute MOVEMENT_SPEED = (new RangedAttribute((IAttribute)null, "generic.movementSpeed", 0.699999988079071D, 0.0D, 1024.0D)).setDescription("Movement Speed").setShouldWatch(true);
    public static final IAttribute FLYING_SPEED = (new RangedAttribute((IAttribute)null, "generic.flyingSpeed", 0.4000000059604645D, 0.0D, 1024.0D)).setDescription("Flying Speed").setShouldWatch(true);
    public static final IAttribute ATTACK_DAMAGE = new RangedAttribute((IAttribute)null, "generic.attackDamage", 2.0D, 0.0D, 2048.0D);
    public static final IAttribute ATTACK_SPEED = (new RangedAttribute((IAttribute)null, "generic.attackSpeed", 4.0D, 0.0D, 1024.0D)).setShouldWatch(true);
    public static final IAttribute ARMOR = (new RangedAttribute((IAttribute)null, "generic.armor", 0.0D, 0.0D, 30.0D)).setShouldWatch(true);
    public static final IAttribute ARMOR_TOUGHNESS = (new RangedAttribute((IAttribute)null, "generic.armorToughness", 0.0D, 0.0D, 20.0D)).setShouldWatch(true);
    public static final IAttribute LUCK = (new RangedAttribute((IAttribute)null, "generic.luck", 0.0D, -1024.0D, 1024.0D)).setShouldWatch(true);

 

which we need to include


import javax.annotation.Nullable;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.SharedMonsterAttributes;

 

 

-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;
	}
Spoiler

This code is directly from 
TheXFactor117 's Forge 1.7 Modding Tutorials  15a

they require 


import net.minecraft.entity.EntityList;
import net.minecraftforge.fml.common.registry.EntityRegistry;

 

 

 

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.