IEntityDefinition

Link to ientitydefinition

This sounds scary, so what does it mean? Basically, it is a reference to an entity registered in the game, so it is a reference to, say a mob in the game.

Importing the package

Link to importing-the-package

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import.
import crafttweaker.entity.IEntityDefinition;

Calling an IEntityDefinition Object

Link to calling-an-ientitydefinition-object

ZenScript
Copy
//These return an IEntityDefinition Object
val test = <entity:minecraft:sheep>;
val test2 = game.getEntity("sheep");

So, this is where it gets interesting: What can we do with it, now that we created that thing?

Returns the ID as string

ZenScript
Copy
//returns "net.minecraft.entity.passive.EntitySheep"
<entity:minecraft:sheep>.id;

Returns the name as string

ZenScript
Copy
//returns "Sheep"
<entity:minecraft:sheep>.name;

The first method only creates an entity on the given location.
The second one also spawns it.
Both methods return the created IEntity.

ZenScript
Copy
<entity:minecraft:sheep>.createEntity(world);
<entity:minecraft:sheep>.spawnEntity(world, blockPos);

world is an IWorld object.
blockPos is an IBlockPos object.

We can even add and/or remove mob drops, isn't that great?

This adds a normal drop, a drop that can occur whenever the mob is killed by whatever means.

ZenScript
Copy
val entity = <entity:minecraft:sheep>;

//addDrop(item,min,max,chance);
entity.addDrop(<minecraft:apple>);

//addDrop(weightedItem, min, max);
entity.addDrop(<minecraft:stone> % 20);

item is the item to be added as drop and an IItemStack or a WeightedItemStack.
min is the minimum amount that is dropped and an Integer. This is optional.
max is the maximum amount that is dropped and an Integer. This is optional.
chance is the drop chance. This is optional. Not needed if you use a weightedItemStack instead as item

Add playeronly drop

Link to add-playeronly-drop

Same as normal drops, but only if the entity was killed by a player.

ZenScript
Copy
//addPlayerOnlyDrop(item,min,max,chance);
entity.addPlayerOnlyDrop(<minecraft:gold_ingot>, 10,64);

//addPlayerOnlyDrop(weightedItem, min, max);
entity.addPlayerOnlyDrop(<minecraft:iron_ingot> % 20, 1, 3);

Add drop Function

Link to add-drop-function

A drop function is called whenever the associated Entity is killed. You can use this if you need to check requirements for before you drop something, like only dropping in a certain biome and stuff.
You will need an IEntityDropFunction:

ZenScript
Copy
<entity:minecraft:sheep>.addDropFunction(function(entity, dmgSource) {
	return <minecraft:iron_ingot> * 10;
	});

This removes a drop.

ZenScript
Copy
val entity = <entity:minecraft:sheep>;

//removeDrop(item);
entity.removeDrop(<minecraft:wool>);

item is the item to be removed from being a drop and an IItemStack.

This removes all drops.

ZenScript
Copy
val entity = <entity:minecraft:sheep>;

//clearDrops
entity.clearDrops();

This returns all drops that were added via CT as list of IEntityDrop Objects.

ZenScript
Copy
val entity = <entity:minecraft:sheep>;

//drops;
val dropList = entity.drops;