Project-RT / RandomTweaker

Provides many more mods support and great features for CraftTweaker.
https://www.curseforge.com/minecraft/mc-mods/randomtweaker
MIT License
21 stars 8 forks source link

[Suggestion: Botania] ability to add mobs to Cocoon of Caprice #50

Closed Biviho closed 2 years ago

Biviho commented 3 years ago

it would be cool to have the ability to add custom mobs to the cocoon of caprice from botania, based on items given.

currently the cocoon work by hatching in an animal after a while, and if up to 20 items are given to it, it will hatch in a shulker or a villager based if you gave it chorus fruits or emeralds (each item add 5% chance)

a function like this could have as parameters: -entity to summon -item to give

if i'm not wrong, things like time to hatch and probability are always 2 minutes and 5% per items, so i don't think it's needed

an other possibility could be to add a pool of entities to summon given the same item, as for normal cocoon behaviour without items.

a function like this could have as parameters: -[list of entities] -[list of probability ordered per entity] -item to give

XHL315 commented 3 years ago

I need some time to understand some things about Botania's API, so I cannot reply you in short time. Of course, it's better if you can create a PR for this suggestion.

XHL315 commented 2 years ago

This function has been completed and is available in the latest version. You can use mods.randomtweaker.botania.ICocoon.registerSpawn(itemGiven as IItemStack, spawnTab as double[IEntityDefinition]); to register

And the probability that in spawnTab cannot exceed 1, the entity that in spawnTab must extend EntityLiving, or this func cannot run properly.

Example

import crafttweaker.entity.IEntityDefinition;
import mods.randomtweaker.botania.ICocoon;

var spawnTab as double[IEntityDefinition] = {
    <entity:minecraft:zombie> : 0.5,
    <entity:minecraft:skeleton> : 0.5
};

var spawnTab2 as double[IEntityDefinition] = {
    <entity:minecraft:slime> : 1.0
};

var spawnTab3 as double[IEntityDefinition] = {
    <entity:minecraft:wither_skeleton> : 1.0
};

ICocoon.registerSpawn(<minecraft:coal:1>, spawnTab);
ICocoon.registerSpawn(<minecraft:iron_ingot>, spawnTab);
ICocoon.registerSpawn(<minecraft:diamond_pickaxe:1>, spawnTab2);
ICocoon.registerSpawn(<minecraft:enchanted_book>.withTag({StoredEnchantments: [{lvl: 1 as short, id: 71 as short}]}), spawnTab3);
XHL315 commented 2 years ago

Sorry, there were some bugs in version 1.2.8, but they have been fixed in version 1.2.9. Also, the way of registration has been changed to mods.randomtweaker.botania.ICocoon.registerSpawn(name as string, itemGiven as IItemStack, spawnTab as double[IEntityDefinition])

Example

import crafttweaker.entity.IEntityDefinition;
import mods.randomtweaker.botania.ICocoon;

var spawnTab as double[IEntityDefinition] = {
    <entity:minecraft:zombie> : 0.5,
    <entity:minecraft:skeleton> : 0.5
};

var spawnTab2 as double[IEntityDefinition] = {
    <entity:minecraft:slime> : 1.0
};

var spawnTab3 as double[IEntityDefinition] = {
    <entity:minecraft:wither_skeleton> : 1.0
};

ICocoon.registerSpawn("spawnZmobileOrSkeleton", <minecraft:iron_ingot>, spawnTab);
ICocoon.registerSpawn("spawnSlime", <minecraft:diamond_pickaxe:1>, spawnTab2);
ICocoon.registerSpawn("spawnWitherSkeleton", <minecraft:enchanted_book>.withTag({StoredEnchantments: [{lvl: 1 as short, id: 71 as short}]}), spawnTab3);