IEntityDefinition

Link to ientitydefinition

Это звучит страшно, что же это значит? В основном, это ссылка на сущность, зарегистрированную в игре, так что это ссылка, на, скажем, моба в игре.

Импорт пакета

Link to импорт-пакета

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;

Вызов объекта IEntityDefinition

Link to вызов-объекта-ientitydefinition

ZenScript
Copy
//Это все возвращает объекты IEntityDefinition
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?

Возвращает ID как строку.

ZenScript
Copy
//возвращает "net.minecraft.entity.passive.EntitySheep"
<entity:minecraft:sheep>.id;

Возвращает имя как строку.

ZenScript
Copy
//возвращает "Sheep"
<entity:minecraft:sheep>.name;

The first method only creates an entity on the given location.
The second one also spawns it.

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

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

Мы даже можем добавлять и/или удалять дроп моба, разве это не прекрасно?

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

addPlayerOnlyDrop

Link to addplayeronlydrop

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

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

Удаляет дроп.

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.

Удаляет весь дроп.

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;