Search in sources :

Example 1 with ILepidopteristTracker

use of forestry.api.lepidopterology.ILepidopteristTracker in project ForestryMC by ForestryMC.

the class ButterflyRoot method getBreedingTracker.

/* BREEDING TRACKER */
@Override
public ILepidopteristTracker getBreedingTracker(World world, @Nullable GameProfile player) {
    String filename = "LepidopteristTracker." + (player == null ? "common" : player.getId());
    LepidopteristTracker tracker = (LepidopteristTracker) world.loadData(LepidopteristTracker.class, filename);
    // Create a tracker if there is none yet.
    if (tracker == null) {
        tracker = new LepidopteristTracker(filename);
        world.setData(filename, tracker);
    }
    tracker.setUsername(player);
    tracker.setWorld(world);
    return tracker;
}
Also used : ILepidopteristTracker(forestry.api.lepidopterology.ILepidopteristTracker)

Example 2 with ILepidopteristTracker

use of forestry.api.lepidopterology.ILepidopteristTracker in project ForestryMC by ForestryMC.

the class EntityButterfly method processInteract.

/* INTERACTION */
@Override
protected boolean processInteract(EntityPlayer player, EnumHand hand) {
    if (isDead) {
        return false;
    }
    ItemStack stack = player.getHeldItem(hand);
    if ((stack.getItem() instanceof IToolScoop)) {
        if (!world.isRemote) {
            IButterflyRoot root = contained.getGenome().getPrimary().getRoot();
            ILepidopteristTracker tracker = root.getBreedingTracker(world, player.getGameProfile());
            ItemStack itemStack = root.getMemberStack(contained.copy(), EnumFlutterType.BUTTERFLY);
            tracker.registerCatch(contained);
            ItemStackUtil.dropItemStackAsEntity(itemStack, world, posX, posY, posZ);
            setDead();
        } else {
            player.swingArm(hand);
        }
        return true;
    }
    return false;
}
Also used : IButterflyRoot(forestry.api.lepidopterology.IButterflyRoot) ILepidopteristTracker(forestry.api.lepidopterology.ILepidopteristTracker) IToolScoop(forestry.api.core.IToolScoop) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ILepidopteristTracker (forestry.api.lepidopterology.ILepidopteristTracker)2 IToolScoop (forestry.api.core.IToolScoop)1 IButterflyRoot (forestry.api.lepidopterology.IButterflyRoot)1 ItemStack (net.minecraft.item.ItemStack)1