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